package com.powernode.crm.transaction.service.impl;

import com.powernode.crm.commons.model.ChartVO;
import com.powernode.crm.transaction.mapper.TranMapper;
import com.powernode.crm.transaction.model.Tran;
import com.powernode.crm.transaction.service.TranService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TranServiceImpl implements TranService {

    @Autowired
    private TranMapper tranMapper;


    /**
     * @param owner
     * @param name
     * @param customerName
     * @param stage
     * @param type
     * @param source
     * @param contactsFullName
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<Tran> queryPages(String owner, String name, String customerName, String stage, String type, String source, String contactsFullName, Integer pageNum, Integer pageSize) {
        /*将参数封装到map集合*/
        Map<String,Object> params  = new HashMap<>();
        /*忽略条件  只做了分页*/
        params.put("pageNum",pageNum);
        params.put("pageSize",pageSize);
        return tranMapper.selectByParams(params);
    }

    /**
     * @param owner
     * @param name
     * @param customerName
     * @param stage
     * @param type
     * @param source
     * @param contactsFullName
     * @return
     */
    @Override
    public int queryCount(String owner, String name, String customerName, String stage, String type, String source, String contactsFullName) {
        Map<String,Object> params  = new HashMap<>();
        return tranMapper.selectCountByParams(params);
    }

    @Override
    public Tran queryById(String id) {
        return  tranMapper.selectById(id);
    }

    @Override
    public List<ChartVO> queryChartVO() {
        return tranMapper.selectChartVo();
    }
}
